(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/resources/Script/Ssg/API/QQ/QQHttp.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, 'cfb7dQttaRMLp2iLbRMDRS/', 'QQHttp', __filename);
// resources/Script/Ssg/API/QQ/QQHttp.js

'use strict';

var QQHttp = cc.Class({

    statics: {
        //QQplay http request
        post: function post(url, param, callback) {
            var self = this;
            var time = false; //是否超时
            var timer = setTimeout(function () {
                //做请求超时操作
                if (timer == null) {
                    return;
                }
                time = true;
                callback(true);
            }, 10000);
            BK.Http.request({
                url: url,
                method: 'POST',
                headers: {
                    'Cookie': "nafosCookie=" + UserInfo.sessionId
                },
                body: param,
                success: function success(succObj) {
                    if (time) {
                        return;
                    }

                    UIHelper.hideLoaing();
                    if (succObj.statusCode != 200) {
                        var failMsg = HttpUtil.getTextWithStatus(succObj.statusCode);
                        AddPrefabHelper.addMsgTipsUI(failMsg, true);
                        return;
                    }
                    callback(succObj);
                },
                fail: function fail(errObj) {
                    UIHelper.hideLoaing();
                    Log.error(url + '请求失败 ', errObj.msg);
                },
                complete: function complete() {
                    //console.log('complete');
                },
                uploadProgress: function uploadProgress(curr, total) {
                    //console.log('upload progress', curr / total);
                },
                downloadProgress: function downloadProgress(curr, total) {
                    //console.log('download progress', curr / total);
                }
            });
        },

        get: function get(url, callback) {
            var self = this;
            var time = false; //是否超时
            var timer = setTimeout(function () {
                //做请求超时操作
                if (timer == null) {
                    return;
                }
                time = true;
                callback(true);
            }, 10000);
            BK.Http.request({
                url: url,
                method: 'GET',
                headers: {
                    'Cookie': "nafosCookie=" + UserInfo.sessionId
                },
                success: function success(succObj) {
                    if (time) {
                        return;
                    }
                    UIHelper.hideLoaing();
                    if (succObj.statusCode != 200) {
                        var failMsg = HttpUtil.getTextWithStatus(succObj.statusCode);
                        AddPrefabHelper.addMsgTipsUI(failMsg, true);
                        return;
                    }
                    callback(succObj);
                },
                fail: function fail(errObj) {
                    UIHelper.hideLoaing();
                    Log.error(url + '请求失败 ', errObj.msg);
                },
                complete: function complete() {
                    //console.log('complete');
                },
                uploadProgress: function uploadProgress(curr, total) {
                    //console.log('upload progress', curr / total);
                },
                downloadProgress: function downloadProgress(curr, total) {
                    //console.log('download progress', curr / total);
                }
            });
        }

    }
});

module.exports = QQHttp;

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=QQHttp.js.map
        